<template>
  <div class="login-container">
    <div class="content-container">
      <div class="title-box">
        <img :src="require('../assets/home/tip_left.png')" alt="" />
        <div>登记</div>
        <img :src="require('../assets/home/tip_right.png')" alt="" />
      </div>
      <input
        class="input-phone"
        type="number"
        placeholder="请输入手机号码"
        v-model="phone"
      />
      <Button title="确定" @btnClick="btnConfirm" />
      <div class="explain-content">
        <p>注意事项：</p>
        <p>1、请核对输入手机号，与兑换手机号码一致，否则将无法核销。</p>
        <p>2、不同号码兑换，请退出重新扫码，输入新手机号码。</p>
      </div>
    </div>
  </div>
</template>

<script>
import Button from "../components/Button.vue";
import { isPhone } from "../utils/index";
export default {
  name: "Login",
  components: {
    Button,
  },
  data() {
    return {
      phone: "",
    };
  },
  created() {
    this._initParams();
  },
  methods: {
    // seller 销售来源 1-001  platesource 对接平台分配  xiangjiangba  都是通过入口url带的参数
    // ?seller=1-001&platesource=xiangjiangba
    _initParams() {
      if (this.$route.query.seller) {
        this.$setSessionItem("seller", this.$route.query.seller);
      }
      if (this.$route.query.platesource) {
        this.$setSessionItem("platesource", this.$route.query.platesource);
      }
    },
    btnConfirm() {
      if (isPhone(this.phone)) {
        console.log("--", this.phone);
        this.$router.push({
          path: "/home",
          query: {
            mobile: this.phone,
            seller: this.$getSessionItem("seller"),
            platesource: this.$getSessionItem("platesource"),
          },
        });
      } else {
        alert("请输入正确格式的手机号码");
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.login-container {
  width: 100%;
  min-height: 100%;
  background-image: url("../assets/login/bg_login.png");
  background-size: 100% 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  box-sizing: border-box;
  .content-container {
    width: 100%;
    box-sizing: border-box;
    padding: 25px 28px;
    background-color: #fff;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    .title-box {
      display: flex;
      justify-content: center;
      align-items: center;
      img {
        width: 27px;
      }
      div {
        color: #ff7700;
        font-size: 20px;
        font-weight: bold;
        margin: 0 15px;
      }
    }
    .input-phone {
      width: 100%;
      height: 45px;
      background-color: #f5f6f7;
      border-radius: 5px;
      outline: none;
      border: none;
      padding: 0 25px;
      box-sizing: border-box;
      font-size: 16px;
      color: #333;
      margin-top: 27px;
      margin-bottom: 30px;
    }
    .explain-content {
      margin-top: 25px;
      margin-bottom: 20px;
      p {
        line-height: 25px;
        color: #9c0d00;
        font-size: 14px;
      }
    }
  }
}
</style>